import os
from langchain_community.chat_models import ChatZhipuAI 
from dotenv import load_dotenv, find_dotenv

from langchain.schema import (
    AIMessage,
    HumanMessage,
    SystemMessage
)

_ = load_dotenv(find_dotenv())

api_key = os.environ.get('ZHIPU_API_KEY')
if api_key is None:
    raise ValueError("API Key is not set in the .env file")

model = os.environ.get('model')
if model is None:
    raise ValueError("model is not set in the .env file")

llm = ChatZhipuAI(api_key=api_key,
                  model=model,
                  temperature=0.9,                 
                )

messages = [
    SystemMessage(content="你是一名实时翻译，你能将用户输入的消息同步翻译成英文和日文。"),
    HumanMessage(content="我是个快乐的小蜜蜂。")
]

result = llm.invoke(messages)
print(result.content)